const scssVariables = require("./src/styles/variables.scss");
const path = require("path");
const resolve = (dir) => path.join(__dirname, dir);

const Separate = require("./src/utils/Separate")

module.exports = {
  css: {
    loaderOptions: {
      sass: {
        // 为了让scss变量能够当做js变量，配置了js版本的scss变量，这里会进行转换
        // 由于scss被uniapp处理过，如果要添加变量需要在uni.scss 和 variables.scss.js 同步配置
        additionalData: Object.keys(scssVariables)
          .map((k) => `$${k}: ${scssVariables[k]};`)
          .join("\n"),
      },
    },
  },

  chainWebpack: (config) => {
    config.resolve.alias.set("@", resolve("src"));
  },

  configureWebpack: {
    plugins: [
      new Separate()
    ]
  }
};
